import numpy as np
import matplotlib.pyplot as plt

def standardized_euclidean_distance(p1, p2, std_dev):
    return np.sqrt(np.sum(((p1 - p2) / std_dev)**2))

# 创建数据点
x = np.linspace(0, 10, 100)
y = np.linspace(0, 10, 100)
X, Y = np.meshgrid(x, y)

# 选择两个点
p1 = np.array([2, 2])
p2 = np.array([8, 8])

# 假设的标准差
std_dev = np.array([2, 1])

# 计算到p1的距离
Z = np.sqrt(((X - p1[0]) / std_dev[0])**2 + ((Y - p1[1]) / std_dev[1])**2)

# 绘制等高线图
plt.figure(figsize=(10, 8))
plt.contourf(X, Y, Z, levels=20, cmap='viridis')
plt.colorbar(label='Standardized Distance from p1')
plt.plot(p1[0], p1[1], 'ro', markersize=10, label='p1')
plt.plot(p2[0], p2[1], 'bo', markersize=10, label='p2')
plt.plot([p1[0], p2[0]], [p1[1], p2[1]], 'r--', linewidth=2)
plt.title('Standardized Euclidean Distance Visualization')
plt.xlabel('X')
plt.ylabel('Y')
plt.legend()
plt.show()

print(f"Standardized Euclidean distance between p1 and p2: {standardized_euclidean_distance(p1, p2, std_dev):.2f}")